﻿using Collaboration_System.DataBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Threading;
using static MaterialDesignThemes.Wpf.Theme;

namespace Collaboration_System
{
    /// <summary>
    /// Логика взаимодействия для Registration.xaml
    /// </summary>
    public partial class Registration : Window
    {
        Collaboration_SystemEntities entities = new Collaboration_SystemEntities();
        Users users = new Users();
        public Registration()
        {
            InitializeComponent();
        }

        private void BackButton_MouseDown(object sender, MouseButtonEventArgs e)
        {
            Autorization autorization = new Autorization();
            autorization.Show();
            Close();
        }

        private void EyeButton_MouseDown(object sender, MouseButtonEventArgs e)
        {

        }

        private void EyeButton2_MouseDown(object sender, MouseButtonEventArgs e)
        {

        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {

        }

        private void ClouseButton_MouseDown(object sender, MouseButtonEventArgs e)
        {
            Close();
        }

        private void Border_MouseDown(object sender, MouseButtonEventArgs e)
        {

        }

        private void SingIn_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(Login.Text) || string.IsNullOrWhiteSpace(Email.Text) || string.IsNullOrWhiteSpace(Password.Password) || string.IsNullOrWhiteSpace(Post.Text) || string.IsNullOrWhiteSpace(DoublePassword.Password))
            {
                MessageBox.Show("В каком-то из полей стоят только пробелы или оно пустое");
            }
            else
            {
                if (Password.Password == DoublePassword.Password)
                {
                    Users registration = new Users() { login = Login.Text, email = Email.Text, password = Password.Password, Position = Post.Text, TaskCount = 0, CompletedTasks = 0, SuccessfulTasks = 0, FailedTasks = 0 };
                    entities.Users.Add(registration);
                    entities.SaveChanges();
                    MessageBox.Show("Пользаватель успешно \nзарегестрирован");
                    Autorization autorization = new Autorization();
                    autorization.Show();
                    Close();
                }
                else
                {
                    MessageBox.Show("Пароли не совподают");
                }
            }
        }

        private void SingIn_Click_1(object sender, RoutedEventArgs e)
        {
           
        }

    }
}
